
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>文章管理页面</title>
    <link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.3.3/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.3.3/themes/icon.css">
    <script type="text/javascript" src="/static/jquery-easyui-1.3.3/jquery.min.js"></script>
    <script type="text/javascript" src="/static/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/static/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>

    <script type="text/javascript">
        function tabsClose(){
            var tab=$('#tabs').tabs('getSelected');//获取当前选中tabs
            var index = $('#tabs').tabs('getTabIndex',tab);//获取当前选中tabs的index
            $('#tabs').tabs('close',index);//关闭对应index的tabs
            addTab('资源信息管理','/news/blogManage');

        }

        function formatTitle(val,row){
          //  return "<a target='_blank' href='/news/cont/"+row.id+".html'>"+val+"</a>"
            return "<a target='_blank' href='http://www.tt.com"+row.img_path+"'>"+val+"</a>";
        }

        function searchBlog(){
            $("#dg").datagrid('load',{
                "title":$("#s_title").val()
            });
        }
        function deleteBlog(){
            var selectedRows=$("#dg").datagrid("getSelections");
            if(selectedRows.length==0){
                $.messager.alert("系统提示","请选择要删除的数据！");
                return;
            }
            var strIds=[];
            for(var i=0;i<selectedRows.length;i++){
                strIds.push(selectedRows[i].id);
            }
            var ids=strIds.join(",");
            $.messager.confirm("系统提示","您确定要删除这<font color=red>"+selectedRows.length+"</font>条数据吗？",function(r){
                if(r){
                    $.post("/news/delete",{ids:ids},function(result){
                        if(result.success){
                            $.messager.alert("系统提示","数据已成功删除！");
                            $("#dg").datagrid("reload");
                        }else{
                            $.messager.alert("系统提示","数据删除失败！");
                        }
                    },"json");
                }
            });
        }


        function openBlogModifyTab(){
            var selectedRows=$("#dg").datagrid("getSelections");
            if(selectedRows.length!=1){
                $.messager.alert("系统提示","请选择一个要修改的博客！");
                return;
            }
            var row=selectedRows[0];
            window.parent.openTab('修改文章','/news/modifyBlog/'+row.id,'icon-writeblog');
        }

    </script>
</head>
<body style="margin: 1px">
<table id="dg" title="资源管理" class="easyui-datagrid"
       fitColumns="true" pagination="true" rownumbers="true"
       url="/index.php/news/index" fit="true" toolbar="#tb">
    <thead>
    <tr>
        <th field="cb" checkbox="true" align="center"></th>
        <th field="id" width="20" align="center">编号</th>
        <th field="name" width="200" formatter="formatTitle">标题</th>
    </tr>
    </thead>
</table>
<div id="tb">
    <div>
        <a href="javascript:openBlogModifyTab()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改</a>
        <a href="javascript:deleteBlog()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
    </div>
    <!--div>
        &nbsp;标题：&nbsp;<input type="text" id="s_title" size="20" onkeydown="if(event.keyCode==13) searchBlog()"/>
        <a href="javascript:searchBlog()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
    </div-->
</div>

</body>
</html>